<template>
  <div class="zst-box">
	<zst-header :title='title'></zst-header>
	<nav class="top-nav">
		<p :class="currentNav==1?'hover':''" @click='currentNav=1'>基本走势<span></span></p>
		<p :class="currentNav==2?'hover':''" @click='currentNav=2'>冷热分析<span></span></p>
		<p :class="currentNav==3?'hover':''" @click='currentNav=3'>大小走势<span></span></p>
		<p :class="currentNav==4?'hover':''" @click='currentNav=4'>奇偶走势<span></span></p>
	</nav>
    <div class="superbox">
		<div class="chart-container">
			<div class="chart-main">
				<div :class="currentNav==1?'page page1 active':'page page1'">
					<div class="nav-com">
						<div class="nav-item" style="display: block;">
							<div class="tit-record">
								<span :class="basicSort?'flex_3 icon_jt_down':'flex_3 icon_jt'" @click='sortData(basic,currentNav)'>期次</span>
								<span>01</span>
								<span>02</span>
								<span>03</span>
								<span>04</span>
								<span>05</span>
								<span>06</span>
								<span>07</span>
								<span>08</span>
								<span>09</span>
								<span>10</span>
								<span>11</span>
							</div>
							<div class="com-record">
								<ul>
									<li v-for='(item,index) in basic' :key='index'>
										<span class="flex_3">{{item.periodId}}</span>
										<template v-for='(items,indexs) in item.origin'>
											<span v-if='items == 0' class="cur"><font>{{(indexs+1)<10?('0'+(indexs+1)):(indexs+1)}}</font></span>
											<span v-else>{{items}}</span>
										</template>
									</li>
								</ul>
							</div>
						</div>
					</div>
					<div class="zd-box">
						<ul>
							<li class="color_red">
								<span class="flex_3 ">出现次数</span>
								<template v-for='(item,index) in basicOther.appearCount'>
									<span>{{item}}</span>
								</template>
							</li>
							<li class="color_gray">
								<span class="flex_3">平均遗漏</span>
								<template v-for='(item,index) in basicOther.avgMiss'>
									<span>{{item}}</span>
								</template>
							</li>
							<li  class="color_blue">
								<span class="flex_3">最大遗漏</span>
								<template v-for='(item,index) in basicOther.maxMiss'>
									<span>{{item}}</span>
								</template>
							</li>
							<li  class="color_black">
								<span class="flex_3">最大连出</span>
								<template v-for='(item,index) in basicOther.maxContinuous'>
									<span>{{item}}</span>
								</template>
							</li>
						</ul>
					</div>
				</div>
				<div :class="currentNav==2?'page page2 active':'page page2'">
					<div class="nav-com">
						<div class="nav-item" style="display: block;">
							<div class="tit-record">
								<span>普通</span>
							</div>
							<div class="tit-record icon-jt">
								<span :class="{'dwon':hotSort,'hover':hotCurrent==1}" @click='hotCurrent=1;sortData(hot,currentNav)'>号码</span>
								<span :class="{'dwon':hotSort,'hover':hotCurrent==2}" @click='hotCurrent=2;sortData(hot,currentNav)'>30期</span>
								<span :class="{'dwon':hotSort,'hover':hotCurrent==3}" @click='hotCurrent=3;sortData(hot,currentNav)'>100期</span>
							</div>
							<div class="com-record">
								<ul>
									<li v-for='(item,index) in hot' :key='index'>
										<span>{{item.num}}</span>
										<span>{{item.hot30}}</span>
										<span>{{item.hot100}}</span>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				<div :class="currentNav==3?'page page3 active':'page page3'">
					<div class="nav-com">
						<div class="nav-item" style="display: block;">
							<div class="tit-record">
								<span :class="bigOrSmallSort?'icon_jt_down':'icon_jt'" @click='sortData(bigOrSmall,currentNav)'><p>期次</p></span>
								<span>
									<p>第一位</p>
									<div>
										<p>大</p>
										<p>小</p>
									</div>
								</span>
								<span>
									<p>第二位</p>
									<div>
										<p>大</p>
										<p>小</p>
									</div>
								</span>
								<span>
									<p>第三位</p>
									<div>
										<p>大</p>
										<p>小</p>
									</div>
								</span>
								<span>
									<p>第四位</p>
									<div>
										<p>大</p>
										<p>小</p>
									</div>
								</span>
								<span>
									<p>第五位</p>
									<div>
										<p>大</p>
										<p>小</p>
									</div>
								</span>
								<span class="flex_3">
									<p>大小比</p>
									<div>
										<p>0:5</p>
										<p>1:4</p>
										<p>2:3</p>
										<p>3:2</p>
										<p>4:1</p>
										<p>5:0</p>
									</div>
								</span>
							</div>
							<div class="com-record">
								<ul>
									<li v-for='(item,index) in bigOrSmall' :key='index'>
										<span class="flex_2">{{item.periodId}}</span>
										<template v-for='(items,indexs) in item.origin'>
											<span v-if='items == 0' :class="indexs>9?'cur_bf':indexs%2==0?'cur_d':'cur_x'"><font>{{bigOrSmallIndex[indexs]}}</font></span>
											<span v-else>{{items}}</span>
										</template>
									</li>
								</ul>
							</div>
						</div>
					</div>
					<div class="zd-box">
						<ul>
							<li class="color_red">
								<span class="flex_2 ">出现次数</span>
								<template v-for='(item,index) in bigOrSmallOther.appearCount'>
									<span>{{item}}</span>
								</template>
							</li>
							<li class="color_gray">
								<span class="flex_2">平均遗漏</span>
								<template v-for='(item,index) in bigOrSmallOther.avgMiss'>
									<span>{{item}}</span>
								</template>
							</li>
							<li  class="color_blue">
								<span class="flex_2">最大遗漏</span>
								<template v-for='(item,index) in bigOrSmallOther.maxMiss'>
									<span>{{item}}</span>
								</template>
							</li>
							<li  class="color_black">
								<span class="flex_2">最大连出</span>
								<template v-for='(item,index) in bigOrSmallOther.maxContinuous'>
									<span>{{item}}</span>
								</template>
							</li>
						</ul>
					</div>
				</div>
				<div :class="currentNav==4?'page page4 active':'page page4'">
					<div class="nav-com">
						<div class="nav-item" style="display: block;">
							<div class="tit-record">
								<span :class="paritySort?'icon_jt_down':'icon_jt'" @click='sortData(parity,currentNav)'><p>期次</p></span>
								<span>
									<p>第一位</p>
									<div>
										<p>奇</p>
										<p>偶</p>
									</div>
								</span>
								<span>
									<p>第二位</p>
									<div>
										<p>奇</p>
										<p>偶</p>
									</div>
								</span>
								<span>
									<p>第三位</p>
									<div>
										<p>奇</p>
										<p>偶</p>
									</div>
								</span>
								<span>
									<p>第四位</p>
									<div>
										<p>奇</p>
										<p>偶</p>
									</div>
								</span>
								<span>
									<p>第五位</p>
									<div>
										<p>奇</p>
										<p>偶</p>
									</div>
								</span>
								<span class="flex_3">
									<p>奇偶比</p>
									<div>
										<p>0:5</p>
										<p>1:4</p>
										<p>2:3</p>
										<p>3:2</p>
										<p>4:1</p>
										<p>5:0</p>
									</div>
								</span>
							</div>
							<div class="com-record">
								<ul>
									<li v-for='(item,index) in parity' :key='index'>
										<span class="flex_2">{{item.periodId}}</span>
										<template v-for='(items,indexs) in item.origin'>
											<span v-if='items == 0' :class="indexs>9?'cur_bf':indexs%2==0?'cur_d':'cur_x'"><font>{{parityIndex[indexs]}}</font></span>
											<span v-else>{{items}}</span>
										</template>
									</li>
								</ul>
							</div>
						</div>
					</div>
					<div class="zd-box">
						<ul>
							<li class="color_red">
								<span class="flex_2">出现次数</span>
								<template v-for='(item,index) in parityOther.appearCount'>
									<span>{{item}}</span>
								</template>
							</li>
							<li class="color_gray">
								<span class="flex_2">平均遗漏</span>
								<template v-for='(item,index) in parityOther.avgMiss'>
									<span>{{item}}</span>
								</template>
							</li>
							<li  class="color_blue">
								<span class="flex_2">最大遗漏</span>
								<template v-for='(item,index) in parityOther.maxMiss'>
									<span>{{item}}</span>
								</template>
							</li>
							<li  class="color_black">
								<span class="flex_2">最大连出</span>
								<template v-for='(item,index) in parityOther.maxContinuous'>
									<span>{{item}}</span>
								</template>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
	<footer class="footer">
		<span :class="currentNum==30?'hover':''" @click='changeBasicData(30,data)'>30期</span>
		<span :class="currentNum==50?'hover':''" @click='changeBasicData(50,data)'>50期</span>
		<span :class="currentNum==100?'hover':''" @click='changeBasicData(100,data)'>100期</span>
	</footer>
  </div>
</template>

<script>
import zstHeader from './head'
import {getTrend} from '@/api/user'
import { Toast } from 'vant';
export default {
	data() {
	    return {
	    	title:'',
	    	data:{},
	    	basic:[],
	    	basicOther:{},
	    	hot:[],
	    	hotOther:{},
	    	bigOrSmall:[],
	    	bigOrSmallOther:{},
	    	parity:[],
	    	parityOther:{},
	    	currentNum:30,
	    	currentNav:'1',
	    	basicSort:false,
	    	hotSort:false,
	    	bigOrSmallSort:false,
	    	paritySort:false,
	    	hotCurrent:1,
			bigOrSmallIndex:['大','小','大','小','大','小','大','小','大','小','0:5','1:4','2:3','3:2','4:1','5:0'],
			parityIndex:['奇','偶','奇','偶','奇','偶','奇','偶','奇','偶','0:5','1:4','2:3','3:2','4:1','5:0']
	    }
	},
	props:['gid','currentNavs'],
	components:{
		zstHeader,
		// [Dialog.Component.name]: Dialog.Component,
	},
	watch: {
	　　　'$route' (to, from) {
			this.getInfo()
		}
	　　　　　
	},
	methods:{
		getData(gid){
			getTrend({"gid":gid}).then((v)=>{
				let data = v.data;
				let status = data.status,mess = data.message;
				if (status === "_0000") {
					data = data.data;
					let hot = [],hot100=[];
					this.basicOther = {
						appearCount:data.basic.appearCount.split(','),
						avgMiss: data.basic.avgMiss.split(','),
						maxContinuous:data.basic.maxContinuous.split(','),
						maxMiss: data.basic.maxMiss.split(',')
					}
					hot100 = data.hot.hot100.split(',');
					hot = data.hot.hot30.split(',').map((v,index)=>{
						let data = {
							num:(index+1)<10?('0'+(index+1)):(index+1),
							hot30:v,
							hot100:hot100[index]
						};
						return data
					})
					this.hot = hot
					this.bigOrSmallOther = {
						appearCount:data.bigOrSmall.appearCount.split(',').concat(data.bigOrSmall.scoreAppearCount.split(',')),
						avgMiss: data.bigOrSmall.avgMiss.split(',').concat(data.bigOrSmall.scoreAvgMiss.split(',')),
						maxContinuous:data.bigOrSmall.maxContinuous.split(',').concat(data.bigOrSmall.scoreMaxContinuous.split(',')),
						maxMiss: data.bigOrSmall.maxMiss.split(',').concat(data.bigOrSmall.scoreMaxMiss.split(',')),
					}
					this.parityOther = {
						appearCount:data.parity.appearCount.split(',').concat(data.parity.scoreAppearCount.split(',')),
						avgMiss: data.parity.avgMiss.split(',').concat(data.parity.scoreAvgMiss.split(',')),
						maxContinuous:data.parity.maxContinuous.split(',').concat(data.parity.scoreMaxContinuous.split(',')),
						maxMiss: data.parity.maxMiss.split(',').concat(data.parity.scoreMaxMiss.split(',')),
					}
					this.data = data;
					this.changeBasicData(30,data);
				}else{
					Toast(mess)
				}
			})
		},
		changeBasicData(num,v){
			let data = v;
			let basicData =  data.basic.trend.slice(0,num),
				bigOrSmallSortData = data.bigOrSmall.trend.slice(0,num),
				paritySortData = data.parity.trend.slice(0,num);
			this.currentNum = num
			basicData = basicData.map((v,index)=>{
				let datas = {}
				Object.assign(datas,v,{'origin':v.origin.split(','),'num':index});
				return datas
			})
			bigOrSmallSortData = bigOrSmallSortData.map((v,index)=>{
				let datas = {}
				let origin = v.origin.split(',');
				origin = origin.concat(v.score.split(','))
				Object.assign(datas,v,{'origin':origin,'num':index});
				return datas
			})
			paritySortData = paritySortData.map((v,index)=>{
				let datas = {}
				let origin = v.origin.split(',');
				origin = origin.concat(v.score.split(','))
				Object.assign(datas,v,{'origin':origin,'num':index});
				return datas
			})
			this.basic = basicData
			this.bigOrSmall = bigOrSmallSortData
			this.parity = paritySortData
		},
		sortData(data,current){
			if (current==1) {
				this.basicSort = !this.basicSort
			}
			if (current==2) {
				this.hotSort = !this.hotSort
			}
			if (current==3) {
				this.bigOrSmallSort = !this.bigOrSmallSort
			}
			if (current==4) {
				this.paritySort = !this.paritySort
			}
			data.sort(function(a,b){
				if (Number(a.num)-Number(b.num)>0) {
					return Number(b.num)-Number(a.num);
				}else{
					return Number(a.num)-Number(b.num);
				}
				
			})
		},
		getInfo(){//初使化
			this.currentNav = this.currentNavs;
			this.title = this.lottery[this.gid].name;
			this.getData(this.gid);
		}
	},
	created(){
		this.getInfo()
	},
	mounted () {
		// let obj = document.getElementsByClassName('chart-container')[0]
  //    	var $this = this
  //     // 监听这个dom的scroll事件
  //    	obj.onscroll  = () => {
  //    		debugger
  //       console.log('on scroll')
  //       // $this.handleScroll()
  //     }
	}
};
</script>

<style lang="less" scoped>
	@import './style.less';
</style>

